<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h1>{{hero}}</h1>
        昵称<input type="text" v-model.lazy="hero"><br>   

        年龄<input v-color='colorinfo' type="text" v-model.number="age"><br>   

        地址<input v-color="colorinfo" type="text" v-model.trim="addr"/> <br>
        <button @click="handle">测试</button>
    </div>
</body>
<script>
// 带参指令
Vue.directive('color',{
  bind: function(el,binding){
    el.style.color = binding.value.color; 
    el.style.backgroundColor = binding.value.bgcolor; 
  }
});

var vm = new Vue({
    el: "#app",
    data: {
        hero:'longgui',
        age: 18,
        addr: '湖南长沙',
        colorinfo: {
            color:'red',
            bgcolor:'yellow'
        }
    },
    methods:{
         handle(){
            // console.log(  this.age + 10 );
            console.log( '地址=', this.addr);
         }
    }
});
</script>
</html>